package com.ruoyi.web.controller.shop.goods.service.impl;

import javax.annotation.Resource;

import com.ruoyi.web.controller.shop.goods.domain.ShopGoods;
import com.ruoyi.web.controller.shop.goods.mapper.ShopGoodsMapper;
import com.ruoyi.web.controller.shop.goods.service.IShopGoodsService;
import com.ruoyi.web.utils.uniquekey.IdGererateFactory;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 店铺商品Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-17
 */
@Service
public class ShopGoodsServiceImpl implements IShopGoodsService 
{
    @Resource
    private IdGererateFactory idGererateFactory;

    @Autowired
    private ShopGoodsMapper shopGoodsMapper;

    /**
     * 查询店铺商品
     * 
     * @param id 店铺商品ID
     * @return 店铺商品
     */
    @Override
    public ShopGoods selectShopGoodsById(String id)
    {
        return shopGoodsMapper.selectShopGoodsById(id);
    }

    /**
     * 查询店铺商品列表
     * 
     * @param shopGoods 店铺商品
     * @return 店铺商品
     */
    @Override
    public List<ShopGoods> selectShopGoodsList(ShopGoods shopGoods)
    {
        return shopGoodsMapper.selectShopGoodsList(shopGoods);
    }

    /**
     * 新增店铺商品
     * 
     * @param shopGoods 店铺商品
     * @return 结果
     */
    @Override
    public int insertShopGoods(ShopGoods shopGoods)
    {
        shopGoods.setId(this.idGererateFactory.nextStringId());
        return shopGoodsMapper.insertShopGoods(shopGoods);
    }

    /**
     * 修改店铺商品
     * 
     * @param shopGoods 店铺商品
     * @return 结果
     */
    @Override
    public int updateShopGoods(ShopGoods shopGoods)
    {
        return shopGoodsMapper.updateShopGoods(shopGoods);
    }

    /**
     * 批量删除店铺商品
     * 
     * @param ids 需要删除的店铺商品ID
     * @return 结果
     */
    @Override
    public int deleteShopGoodsByIds(String[] ids)
    {
        return shopGoodsMapper.deleteShopGoodsByIds(ids);
    }

    /**
     * 删除店铺商品信息
     * 
     * @param id 店铺商品ID
     * @return 结果
     */
    @Override
    public int deleteShopGoodsById(String id)
    {
        return shopGoodsMapper.deleteShopGoodsById(id);
    }

    @Override
    public Integer findSumGoods(String id) {
        return this.shopGoodsMapper.findSumGoods(id);
    }
}
